from application import app, db, manager
from config.local_setting import SQLALCHEMY_DATABASE_URI
from www import *
from flask_script import Server, Command
from jobs.launcher import runJob

# webServer
manager.add_command("runserver", Server(host="0.0.0.0", use_debugger=True, use_reloader=True))

# from jobs.moveJob import MovieJob
#
manager.add_command("runJob", runJob)


@Command
def create_all():
    from application import db
    from common.models.user import User
    db.create_all()
    print(db)


manager.add_command("create_all", create_all)


def main():
    manager.run()


if __name__ == '__main__':
    # app.run(host="0.0.0.0",debug=True)
    # manager.run()
    try:
        # pass
        import sys

        sys.exit(main())
    except Exception as e:
        import traceback

        traceback.print_exc()
